GuiSGML Examples


Welcome to GuiSGML Examples

GuiSGML documentation is stored in templated SGML files which can be used to understand GuiSGML. Both the source and published form of the documentation is in the archive.
Basic Example, TEMPLATE APPEND argument, Advanced Example (Args)



Basic Example

This is a very basic example with a body in a template. The template is defined by NEWTEMPLATE and is named using the NAME= argument (BODYTEMPLATE). The contents between the NEWTEMPLATE and /NEWTEMPLATE is what will be used when this template is referenced. The template is referenced in the source document by TEMPLATE, using NAME to specify the template you want at this point in the file.

Using this technique on a whole site can allow you to change the colours of ALL the web pages by changing the BODY in the template, and re-publishing the whole site. Only 1 file edit, wow. GuiSGML checks the date of the destination file if it already exists and ONLY overwrites it if the source (or templates used by it) changed since the destination file was written.

This makes it easy to write scripts to upoad files to a server based on todays date - much more efficient.

The interesting thing to note in this example is the /BODY in the source file, but no BODY because that is in the template. This ensures that the BODY has a matching /BODY once the file is parsed (see the published file). However, there is a better solution than having these /BODY tags hanging around. More on that later.
Template FileSource File
<NEWTEMPLATE NAME=BODYTEMPLATE>
<BODY BGCOLOR=blue>
</NEWTEMPLATE>
<HTML>
<TEMPLATE NAME=BODYTEMPLATE>
Hello World
</TEMPLATE>
</BODY>
</HTML>
Published File
<HTML>
<BODY BGCOLOR=blue>
Hello World

</BODY>
</HTML>

As you will see in the next example the /BODY has been dropped, but a new argument has been added (APPEND=/BODY) to the TEMPLATE directive in the source file to automatically add the /BODY. This will be added at the end of the template, where the /TEMPLATE is.



APPEND Argument

Template FileSource File
Using the same template as above
<NEWTEMPLATE NAME=BODYTEMPLATE>
<BODY BGCOLOR=blue>
</NEWTEMPLATE>
<HTML>
<TEMPLATE NAME=BODYTEMPLATE APPEND=/BODY>
Hello World
</TEMPLATE>
</HTML>
Published File
<HTML>
<BODY BGCOLOR=blue>
Hello World
</BODY>
</HTML>


Advanced Example - Arguments

This example passes some text to a template as an argument. This is useful for HTML links, you can use the same link in different files but with different text. This means if the URL changes, only the template needs to be updated.

To pass an argument, add to the NEWTEMPLATE directive an argument name, URLTEXT in this case. Then in the template itself, reference the argname with a $ or $(), eg $URLTEXT or $(URLTEXT), When you reference a template simply add the argument name to the TEMPLATE directive as shown below. If the argument isn't supplied, an environment variable is looked for. If there isn't an environment variablethe template will parse out the variable reference so it doesn't show.
Template File
<NEWTEMPLATE NAME=LINKARG1 URLTEXT>
<A ALT="$URLTEXT" HREF="http://www.geocities.com/SiliconValley/7499/">$URLTEXT</A>
</NEWTEMPLATE>
Source File
<HTML><TITLE>Template Argument Example</TITLE>
<TEMPLATE NAME=LINKARG1 URLTEXT="Display Text 1">
<BR>
<TEMPLATE NAME=LINKARG1 URLTEXT="Display Text 2">
</HTML>
Published File
<HTML><TITLE>Template Argument Example</TITLE>
<A ALT="Display Text 1" HREF="http://www.geocities.com/SiliconValley/7499/">Display Text 1</A>
<BR>
<A ALT="Display Text 2" HREF="http://www.geocities.com/SiliconValley/7499/">Display Text 2</A>
</HTML>


Questions? Drop the author an email.